drop database if exists duckweed_codegen;
create database duckweed_codegen default character set utf8mb4 collate utf8mb4_general_ci;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for gen_api_file
-- ----------------------------
DROP TABLE IF EXISTS `gen_api_file`;
CREATE TABLE `gen_api_file` (
  `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `file_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  PRIMARY KEY (`file_path`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of gen_api_file
-- ----------------------------
BEGIN;
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/', 'this is directory');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/', 'this is directory');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/group.json', '{\n  \"properties\" : { },\n  \"id\" : \"tadpole_strategy_undo_log\",\n  \"name\" : \"tadpole_strategy_undo_log\",\n  \"type\" : \"api\",\n  \"parentId\" : \"0\",\n  \"path\" : \"/api/dynamic/tadpole_strategy/undo_log\",\n  \"createTime\" : 1669186638930,\n  \"updateTime\" : null,\n  \"createBy\" : null,\n  \"updateBy\" : null,\n  \"paths\" : [ ],\n  \"options\" : [ ]\n}');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/修改.ms', '{\n  \"properties\" : { },\n  \"id\" : \"tadpole_strategy_undo_log_update\",\n  \"script\" : null,\n  \"groupId\" : \"tadpole_strategy_undo_log\",\n  \"name\" : \"修改\",\n  \"createTime\" : 1669186639041,\n  \"updateTime\" : null,\n  \"lock\" : null,\n  \"createBy\" : null,\n  \"updateBy\" : null,\n  \"path\" : \"/update\",\n  \"method\" : \"put\",\n  \"parameters\" : [ ],\n  \"options\" : [ ],\n  \"requestBody\" : null,\n  \"headers\" : [ ],\n  \"paths\" : [ ],\n  \"responseBody\" : null,\n  \"description\" : null,\n  \"requestBodyDefinition\" : null,\n  \"responseBodyDefinition\" : null\n}\r\n================================\r\nimport response;\n\nvar data = db.tadpole_strategy.table(\"undo_log\").primary(\"id\").update(body)\n\nreturn response.json(data)\n');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/分页.ms', '{\n  \"properties\" : { },\n  \"id\" : \"tadpole_strategy_undo_log_query\",\n  \"script\" : null,\n  \"groupId\" : \"tadpole_strategy_undo_log\",\n  \"name\" : \"分页\",\n  \"createTime\" : 1669186638980,\n  \"updateTime\" : null,\n  \"lock\" : null,\n  \"createBy\" : null,\n  \"updateBy\" : null,\n  \"path\" : \"/list\",\n  \"method\" : \"post\",\n  \"parameters\" : [ ],\n  \"options\" : [ ],\n  \"requestBody\" : null,\n  \"headers\" : [ ],\n  \"paths\" : [ ],\n  \"responseBody\" : null,\n  \"description\" : null,\n  \"requestBodyDefinition\" : null,\n  \"responseBodyDefinition\" : null\n}\r\n================================\r\nimport request;\nimport cn.hutool.json.JSONUtil;\nimport response;\n\nvar queryDsl = db.tadpole_strategy.table(\"undo_log\")\n.where()\n.eq(\"del_flag\", 0)\n\nif (query != null) {\n    var jsonObj = JSONUtil.parseObj(query)\n    for (key in jsonObj.keySet()) {\n        queryDsl.like(key, \"%\" + jsonObj.get(key) + \"%\")\n    }\n}\n\n// 执行DSL 输出结果\nreturn response.json(queryDsl.page())\n');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/删除.ms', '{\n  \"properties\" : { },\n  \"id\" : \"tadpole_strategy_undo_log_del\",\n  \"script\" : null,\n  \"groupId\" : \"tadpole_strategy_undo_log\",\n  \"name\" : \"删除\",\n  \"createTime\" : 1669186639011,\n  \"updateTime\" : null,\n  \"lock\" : null,\n  \"createBy\" : null,\n  \"updateBy\" : null,\n  \"path\" : \"/delete\",\n  \"method\" : \"delete\",\n  \"parameters\" : [ ],\n  \"options\" : [ ],\n  \"requestBody\" : null,\n  \"headers\" : [ ],\n  \"paths\" : [ ],\n  \"responseBody\" : null,\n  \"description\" : null,\n  \"requestBodyDefinition\" : null,\n  \"responseBodyDefinition\" : null\n}\r\n================================\r\nimport response;\n\nvar data = db.tadpole_strategy.table(\"undo_log\").primary(\"id\").update({\nid: id,\ndel_flag: 1\n})\n\nreturn response.json(data)\n');
INSERT INTO `gen_api_file` VALUES ('/magic-api/api/tadpole_strategy_undo_log/添加.ms', '{\n  \"properties\" : { },\n  \"id\" : \"tadpole_strategy_undo_log_add\",\n  \"script\" : null,\n  \"groupId\" : \"tadpole_strategy_undo_log\",\n  \"name\" : \"添加\",\n  \"createTime\" : 1669186639026,\n  \"updateTime\" : null,\n  \"lock\" : null,\n  \"createBy\" : null,\n  \"updateBy\" : null,\n  \"path\" : \"/save\",\n  \"method\" : \"post\",\n  \"parameters\" : [ ],\n  \"options\" : [ ],\n  \"requestBody\" : null,\n  \"headers\" : [ ],\n  \"paths\" : [ ],\n  \"responseBody\" : null,\n  \"description\" : null,\n  \"requestBodyDefinition\" : null,\n  \"responseBodyDefinition\" : null\n}\r\n================================\r\nimport com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;\nimport response;\nimport log;\n\nvar dbId = new DefaultIdentifierGenerator().nextId(null)\nreturn db.tadpole_strategy.table(\"undo_log\").primary(\"id\", dbId).save(body)\n');
INSERT INTO `gen_api_file` VALUES ('/magic-api/datasource/', 'this is directory');
INSERT INTO `gen_api_file` VALUES ('/magic-api/function/', 'this is directory');
COMMIT;

-- ----------------------------
-- Table structure for gen_datasource_conf
-- ----------------------------
DROP TABLE IF EXISTS `gen_datasource_conf`;
CREATE TABLE `gen_datasource_conf` (
  `id` bigint NOT NULL COMMENT '主键',
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '别名',
  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'jdbcurl',
  `username` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户名',
  `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '密码',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '删除标记',
  `tenant_id` bigint DEFAULT NULL COMMENT '租户ID',
  `ds_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '数据库类型',
  `conf_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '配置类型',
  `ds_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '数据库名称',
  `instance` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '实例',
  `port` int DEFAULT NULL COMMENT '端口',
  `host` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '主机',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='数据源表';

-- ----------------------------
-- Records of gen_datasource_conf
-- ----------------------------
BEGIN;
INSERT INTO `gen_datasource_conf` VALUES (1593213208955068417, 'tadpole_user', 'jdbc:mysql://192.168.0.230:3306/tadpole_user?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&allowMultiQueries=true&allowPublicKeyRetrieval=true', 'root', 'Y85LhoX0V7wy/HJgU++HGA==', '2022-11-17 20:03:24', '2022-11-17 20:03:24', '0', 1, 'mysql', '0', 'tadpole_user', NULL, 3306, '192.168.0.230');
INSERT INTO `gen_datasource_conf` VALUES (1595310130790457346, 'tadpole_strategy', 'jdbc:mysql://192.168.0.230:3306/tadpole_strategy?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&allowMultiQueries=true&allowPublicKeyRetrieval=true', 'root', 'zSyKHfjKhj28kZy+8x1fIg==', '2022-11-23 14:55:49', '2022-11-23 14:55:49', '0', 1, 'mysql', '0', 'tadpole_strategy', NULL, 3306, '192.168.0.230');
INSERT INTO `gen_datasource_conf` VALUES (1595311694418599938, 'tadpole_system', 'jdbc:mysql://192.168.0.230:3306/tadpole_system?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&allowMultiQueries=true&allowPublicKeyRetrieval=true', 'root', 'SY95ID+G8T7xlX/93gELZw==', '2022-11-23 15:02:02', '2022-11-23 15:02:02', '0', 1, 'mysql', '0', 'tadpole_system', NULL, 3306, '192.168.0.230');
COMMIT;

-- ----------------------------
-- Table structure for gen_form_conf
-- ----------------------------
DROP TABLE IF EXISTS `gen_form_conf`;
CREATE TABLE `gen_form_conf` (
  `id` bigint NOT NULL COMMENT 'ID',
  `table_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `form_info` json NOT NULL COMMENT '表单信息',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0',
  `tenant_id` bigint DEFAULT NULL COMMENT '所属租户',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `table_name` (`table_name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='表单配置';

-- ----------------------------
-- Records of gen_form_conf
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
